<?php
declare (strict_types = 1);
/**
 * 公共
 * User: ZengYou
 * Date: 2020/2/15 13:38
 * Created by : PhpStorm
 */
namespace app\common\model;

use think\Model;

class BaseModel extends Model
{

    /**
     * 详情
     */
    public function info($param = [], $field = '*')
    {
        return self::field($field)->where($param)->find();
    }

    /**
     * 列表【所有】
     */
    public function listsAll($where = [], $field = [], $order = 'addTime DESC')
    {
        return self::field($field)->where($where)->order($order)->select();
    }

    /**
     * 添加或者保存
     */
    public function addEditSave($param = [], $where = [])
    {

        $time              = time();
        $param['addTime']  = $time;
        $param['editTime'] = $time;

        $save = self::where($where)->save($param);

        if ($save === false) exception('添加失败');

        return $save;
    }

}
